package cn.psvmc.cxzapi.task;

import cn.psvmc.cxzapi.service.order.TOrderTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author ywx 订单定时任务
 * @className OrderTask
 * @description
 * @date 2024/9/28 16:23
 **/
@Slf4j
@Component
public class OrderTask {
    @Resource
    private TOrderTaskService orderTaskService;

    /**
     * @Description 定时支付宝生成交易号
     * @Date 2024/9/28 22:41
     * @Author YWX
     * @Param []
     * @Return void
     **/
    /*@Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.tradeNo}")
    public void generateTradeNo() {
        orderTaskService.generateTradeNo();
    }*/

    /**
     * @Description 更新待归还订单状态--每天凌晨1点
     * @Date 2024/9/28 23:14
     * @Author YWX
     * @Param []
     * @Return void
     **/
    @Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.tradeNo}")
    public void updateOrderStatus() {
        orderTaskService.updateOrderStatus();
    }

    /**
     * @Description 定时取消订单--每隔1分钟取消30分钟未支付押金的订单
     * @Date 2024/10/27 20:50
     * @Author YWX
     * @Param []
     * @Return void
     **/
    @Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.cancelOrder}")
    public void cancelOrder() {
        orderTaskService.cancelOrder();
    }

    /**
     * @Description 账单代扣定时任务--每隔10分钟执行账单代扣
     * @Date 2024/11/30 15:28
     * @Author YWX
     * @Param []
     * @Return void
     **/
    @Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.tradePay}")
    public void tradePay() {
        orderTaskService.tradePay();
    }
}
